package com.cn.wanxi.util;

import java.io.*;

public class ReadNote {
    public static String readCompany(String path) {
        File file = new File(path);//将地址加载到类里面
        StringBuilder stringBuilder = new StringBuilder();

        boolean isExists = file.exists();
        //如果不存，则告诉客户不能进行读取，请重新输入地址
        if (isExists) {
            try {
//                InputStream inputStream = new FileInputStream(path);
//                int a = inputStream.read();
////                for (int i=0;i<changdu;i++)
////                while(i!=-1)
//                while ((a = inputStream.read()) != -1) {
//                    System.out.print((char) a);
//                }
//                String aa="";
                Reader reader = new FileReader(path);
                int a = 0;
                while ((a = reader.read()) != -1) {
                    stringBuilder.append((char) a);
//                    System.out.print((char) a);
//                    aa+=(char) a;
                }
//                System.out.println(stringBuilder);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return stringBuilder.toString();
        } else {
            return "你输入的地址有错误";
        }
    }
}
